Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

content-disposition

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

content-disposition

Create and parse Content-Disposition header

  • 0.5.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35M
increased by11.3%
Maintainers
1
Weekly downloads
 
Created

What is content-disposition?

The content-disposition npm package is used to create and parse HTTP Content-Disposition headers. It is commonly used to set the disposition type (inline or attachment) and parameters for a response in a web application, which instructs the browser how to handle the content, such as to display it inline or to download it as a file.

What are content-disposition's main functionalities?

Creating Content-Disposition header for attachment

This code sample demonstrates how to create a Content-Disposition header for an attachment, suggesting the browser to download the file as 'filename.txt'.

const contentDisposition = require('content-disposition');
let header = contentDisposition('filename.txt');

Creating Content-Disposition header with Unicode filenames

This code sample shows how to create a Content-Disposition header for a file with a Unicode filename, ensuring proper encoding for non-ASCII characters.

const contentDisposition = require('content-disposition');
let header = contentDisposition('filename.txt', { type: 'attachment', filename: 'файл.txt' });

Parsing Content-Disposition header

This code sample illustrates how to parse a Content-Disposition header string to get an object representing the disposition type and parameters.

const contentDisposition = require('content-disposition');
let parsedHeader = contentDisposition.parse('attachment; filename="filename.txt"');

Other packages similar to content-disposition

Keywords

FAQs

Package last updated on 10 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc